package com.sky.controller.user;

import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController(value = "userSetmealController")
@Slf4j
@RequestMapping("/user/setmeal")
public class SetmealController {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private SetmealService setmealService;
    /**
     * 根据分类id查询套餐
     */
    @Cacheable(cacheNames = "setmealCache",key = "#categoryId")
    @GetMapping("/list")
    public Result<List<Setmeal>> setmealList(Long categoryId){
        List<Setmeal> list = setmealService.selectByCategoryId(categoryId);
        return Result.success(list);
    }
}
